/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package group2assignone.ucm.manager;

import group2assignone.dao.MyDAO;
import group2assignone.model.Flight;
import group2assignone.ucm.UCController;
import group2assignone.ucm.UCStartup;
import group2assignone.view.manager.AddPromotionView;
import group2assignone.view.manager.ManagerView;

/**
 *
 * @author Brad
 */
class UCAddPromotionSave implements UCController{

 private AddPromotionView promoView = new AddPromotionView();
    private Flight f;// = new Flight();

    /**
     * sets view and flight
     * @param eView
     * @param flight
     */
    public UCAddPromotionSave(AddPromotionView eView, Flight flight) {
        promoView = eView;
        f = flight;

    }

    @Override
    public void run() {
        //save details
        f = promoView.LoadDetails();
System.out.println("in save promotion");
        System.out.println("flight num = " + f.getFlightNum());
        
        MyDAO coms = UCStartup.getInstance().getDAO();
        
        coms.sQLAddPromotion(f);
        //go back to main login screen
        promoView.dispose();
        ManagerView mv = ManagerView.getInstance();
        mv.setVisible(true);
    }

}
